#include "src/scene/ambientLight.h"

#include <iostream>

#include "src/scene/material.h"

AmbientLight::AmbientLight() : Light() {
}

AmbientLight::AmbientLight(unsigned int _id, const Color &_c) : Light(_id, _c){
}

AmbientLight::~AmbientLight(){
}

Color AmbientLight::getIntersectionColor(const NearestInfo &_nearest, const Vector3D &, HBBTree *, const unsigned int &) const
{

    Material material = _nearest.object->getMaterial();

    Color materialAmbient = material.ambient;
    if(material.useTexture() && (material.texture->coloringType == REPLACE))
    {
        materialAmbient = _nearest.texture;
    }
//    #if DEBUG
//    std::cout <<"NA LUZ \n\tcor";
//    color.print();
//    std::cout <<"\n\tka" << material.ka << "\n\tcor do objeto";
//    material.ambient.print();
//    #endif //DEBUG

    return color * material.ka * materialAmbient;
}

void AmbientLight::shine(const GLenum &)
{
    GLfloat color__[4];
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, color.toGL(color__));
}
